package com.yc.jpyy.gpsposition.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import com.yc.jpyy.base.service.BaseService;
import com.yc.jpyy.base.util.PageBean;
import com.yc.jpyy.gpsposition.dao.GPSPositionDao;
import com.yc.jpyy.gpsposition.service.GPSPositionService;





@Service
public class GPSPositionServiceImpl extends BaseService implements GPSPositionService {
    
	@Autowired
	private GPSPositionDao gpsPositionDao;

	

	@Override
	public int addGPSPositionService(Map<String, Object> paramsMap) throws DataAccessException {
		int ret = gpsPositionDao.addGPSPositionDao(paramsMap);
		System.out.println(ret);
		return ret;
	}

	@Override
	public int updateGPSPositionService(Map<String, Object> paramsMap) throws DataAccessException {
		int ret = gpsPositionDao.updateGPSPositionDao(paramsMap);
		return ret;
		
	}

	
	
	

	@Override
	public List<Map<String, Object>> findGPSPositionByCarIdService(Map<String, Object> paramsMap) throws DataAccessException {
	     return gpsPositionDao.findGPSPositionByCarIdDao(paramsMap);
	}

	

	@Override
	public PageBean findGPSPositionService(Map<String, Object> paramsMap) throws DataAccessException {
		int pagenum = Integer.parseInt(paramsMap.get("pagenum").toString());
		int pagesize = Integer.parseInt(paramsMap.get("pagesize").toString());
		paramsMap.put("pagestart", (pagenum-1) * pagesize);
		List list = gpsPositionDao.findGPSPositionDao(paramsMap);
		PageBean pageBean = new PageBean();
		pageBean.setList(list);
		// 每页几条数据，默认20条
		pageBean.setPageSize(pagesize);
		// 得到数据库中的条数
		pageBean.setAllRow(this.findCountGPSPositionService(paramsMap));
		// 当前第几页，默认第一页
		pageBean.setCurrentPage(pagenum);
		// 得到一共几页
		pageBean.setTotalPage(pageBean.getTotalPage());
		// 模仿百度分页，只显示10条数据
		pageBean.paginationTool(pagenum, pageBean.getTotalPage());
		return pageBean;
	}

	@Override
	public int findCountGPSPositionService(Map<String, Object> paramsMap) throws DataAccessException {
		return gpsPositionDao.findCountGPSPositionDao(paramsMap);
	}

	@Override
	public int delGPSPositionService(Map<String, Object> InvestigInfo) throws DataAccessException {
		return gpsPositionDao.delGPSPositionDao(InvestigInfo);
	}

	
	


	
}
